/*
 *	Copyright (C) Ergobyte Informatics S.A. - All Rights Reserved
 *
 * 	This material is proprietary to Ergobyte. The methods and techniques described herein are considered trade secrets
 *	and/or confidential. Reproduction or distribution, in whole or in part, is forbidden except by express written permission.
 */
package com.ergobyte.servo.client;

import org.apache.http.HttpStatus;

public abstract class Result {

	private int statusCode;

	protected Result(int statusCode) {
		this.statusCode = statusCode;
	}

	public int getStatusCode() {
		return statusCode;
	}

	public boolean isOK() {
		return statusCode == HttpStatus.SC_OK;
	}

	public static class StatusResult extends Result {

		public static final StatusResult OK = new StatusResult(HttpStatus.SC_OK, null);

		private String reasonPhrase;

		public StatusResult(int statusCode, String reasonPhrase) {
			super(statusCode);
			this.reasonPhrase = reasonPhrase;
		}

		public String getReasonPhrase() {
			return reasonPhrase;
		}
	}

	public static class JsonResult extends Result {

		private Object value;

		public JsonResult(Object value) {
			super(HttpStatus.SC_OK);
			this.value = value;
		}

		public Object getValue() {
			return value;
		}
	}
}
